$(document).ready(function() {
    $.getJSON('/backend/get-data?data=member-active-expire', function(items) {
        pie_chart('activation', 'Activation/Expiration Share', items)
    })


    function lazy_load(section_id, title) {
        $('a[href="#'+section_id+'"]').click(function(e) {
            if(! $(this).data('shown')) {
                $(this).data('shown', true)
                $.getJSON('/backend/get-data?data=member-'+section_id, function(items) {
                    pie_chart(section_id, title, items)
                })
            }
        })
    }

    lazy_load('gender', 'Gender Share')
    lazy_load('age', 'Age Group Share')
    lazy_load('location', 'Province Share')
    lazy_load('level', 'Level Share')
})
